package com.therandoms.rtgdroid;

import java.util.ArrayList;

import org.codepond.wizardroid.WizardFlow;
import org.codepond.wizardroid.layouts.BasicWizardLayout;
import org.codepond.wizardroid.persistence.ContextVariable;
import org.therandoms.textgen.TextGeneratorDictionary;
import org.therandoms.textgen.WordnikOptions;

import android.os.Bundle;

import com.therandoms.rtgdroid.steps.FinalResultsStep;
import com.therandoms.rtgdroid.steps.GrammarFileChooserStep;
import com.therandoms.rtgdroid.steps.ProductionCategorySelectionStep;
import com.therandoms.rtgdroid.steps.RandomTextResultsStep;
import com.therandoms.rtgdroid.steps.SecondarySubstitutionSettingsStep;
import com.therandoms.rtgdroid.steps.WordnikLoadingStep;
import com.therandoms.rtgdroid.steps.WordnikWordsStep;

/**
 * A simple wizard for making random text. This ensures that the multi-step
 * process of making random text remains as modular as possible.
 * 
 * @author Logan Widick
 *
 */
public class RandomTextGenWizard extends BasicWizardLayout {
	/**
	 * The grammar to use for randomly making text. Persisted across wizard
	 * fragments with the ContextVariable annotation.
	 */
	@ContextVariable
	private TextGeneratorDictionary<String> grammar = new TextGeneratorDictionary<String>();

	/**
	 * The production categories to use for randomly generating text. Persisted
	 * across wizard fragments with the ContextVariable annotation.
	 */
	@ContextVariable
	private ArrayList<String> desiredProductionCategories = new ArrayList<String>();
	
	/**
	 * Stores the words generated. 
	 */
	@ContextVariable
	private ArrayList<String> outList = new ArrayList<String>();
	
	/**
	 * Stores the words to pass to the secondary substitution grammar. 
	 */
	@ContextVariable
	private ArrayList<String> secondarySubstituteList = new ArrayList<String>();
	
	/**
	 * Stores the words retrieved from wordnik. 
	 */
	@ContextVariable
	private ArrayList<WordnikOptions> optionsToLoad = new ArrayList<WordnikOptions>();

	/**
	 * Default constructor.
	 */
	public RandomTextGenWizard() {
		super();
	}

	@Override
	public WizardFlow onSetup() {
		// add steps here between new WizardFlow.Builder() and .create()
		return new WizardFlow.Builder()
				.addStep(GrammarFileChooserStep.class, true)
				.addStep(WordnikLoadingStep.class)
				.addStep(WordnikWordsStep.class)
				.addStep(ProductionCategorySelectionStep.class, true)
				.addStep(RandomTextResultsStep.class)
				.addStep(SecondarySubstitutionSettingsStep.class, true)
				.addStep(FinalResultsStep.class).create();
	}

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
	}

	@Override
	public void onWizardComplete() {
		super.onWizardComplete();
		getActivity().finish();
	}

}
